#!/usr/bin/env python
# -*- coding=utf-8 -*-
"""
@author: xingwg
@license: (C) Copyright 2020-2025.
@contact: xingweiguo@chinasvt.com
@project: boya-reid
@file: analyze_img.py
@time: 2020/9/21 13:32
@desc:
"""
# import cv2
#
# cv_image = cv2.imread("../../data/img_2.png")
#
# hsv = cv2.cvtColor(cv_image, cv2.COLOR_BGR2HSV)
#
# h, s, v = cv2.split(hsv)
#
# h = cv2.equalizeHist(h)
# s = cv2.equalizeHist(s)
# v = cv2.equalizeHist(v)
#
# hsv = cv2.merge([h, s, v])
#
# img = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
#
# cv2.imshow("see", img)
# cv2.waitKey()

import matplotlib.pyplot as plt
import numpy as np
import cv2

img = cv2.imread("../../data/img_2.png")
bins = np.arange(256)

item = img[:, :, 0]
hist, bins = np.histogram(item, bins)
width = (bins[1] - bins[0])
center = (bins[:-1] + bins[1:]) / 2
plt.bar(center, hist, align='center', width=width)
plt.show()
